package com.framework.websocket.example.config;

import com.framework.websocket.core.SubscriptionConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;

/**
 * 自定义订阅类型配置
 * 演示如何动态添加新的订阅类型
 */
@Configuration
public class CustomSubscriptionConfig implements CommandLineRunner {
    
    @Autowired
    private SubscriptionConfig subscriptionConfig;
    
    @Override
    public void run(String... args) throws Exception {
        // 动态注册新的订阅类型
        subscriptionConfig.registerSubscriptionType(
            "SENSOR_DATA",           // 订阅类型名称
            "sensor:data:",          // Redis键前缀
            "传感器数据变化通知"      // 描述信息
        );
        
        subscriptionConfig.registerSubscriptionType(
            "ORDER_STATUS",
            "order:status:",
            "订单状态变更通知"
        );
        
        subscriptionConfig.registerSubscriptionType(
            "INVENTORY_CHANGE",
            "inventory:change:",
            "库存变化通知"
        );
        
        // 可以根据业务需求添加更多订阅类型
    }
}